package mk.company.fin.frame.internal;

import java.awt.Dimension;
import java.beans.PropertyVetoException;

import javax.swing.JFrame;

import mk.company.fin.AppConstants;
import mk.company.fin.service.MessageService;

import org.springframework.context.ApplicationContext;

public class OrganizationFrame extends AbstractInternalFrame {

	private static final long serialVersionUID = -927314206394189041L;

	/* SERVICES */
	
	private MessageService messageService;
	
	@Override
	public void initialize(ApplicationContext context) {
		setContext(context);
		injectServices();
		// Defaults
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(new Dimension(AppConstants.MainFrame.WIDTH, AppConstants.MainFrame.HEIGHT));
		
		// components
		initComponents();
	}
	
	/**
	 * Inject services.
	 */
	private void injectServices() {
		messageService = getContext().getBean(MessageService.class);
	}
	@Override
	public void draw() {
		injectServices();
		initComponents();
	}
	
	public void initComponents(){
		// title
		setTitle(messageService.getMessage("inputFinancialOrder.title"));
		//Size
		this.setSize(AppConstants.MainFrame.WIDTH, AppConstants.MainFrame.HEIGHT);
		//Maximize
		try {
			this.setMaximum(true);
		} catch (PropertyVetoException e) {}
		catch (NullPointerException n){}
		//Layout
		this.setLayout(null);
	}

}
